<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text">
    <button>提交</button>
    <ul>
        <li>苹果</li>
    </ul>
    <script>
        let inp=document.querySelector("input");
        let but=document.querySelector("button");
        let ul=document.querySelector("ul");
        but.addEventListener("click",function(){
            let li=document.createElement("li");
            let val=inp.value;
            let txt=document.createTextNode(val)
            ul.appendChild(li);
            li.appendChild(txt);
            inp.value="";
        })
        ul.addEventListener("click",function(e){
            ul.removeChild(e.target)
        })
    </script>
</body>
</html>